#!/system/bin/sh

# BMc's sh script.......ZOOM ZOOM
# enable crond
echo "root:x:0:0::data/cron:/system/xbin/bash" > /system/etc/passwd
mount -o remount,rw rootfs /
ln -s /system/xbin /xbin
mount -o remount,ro rootfs /
timezone='date +%z'
if [ $timezone = "0800" ]; then
  TZ=PST8PDT
elif [ $timezone = "-0700" ]; then
  TZ=MST7MDT
elif [ $timezone = "-0600" ]; then
  TZ=CST6CDT
elif [ $timezone = "-0500" ]; then
  TZ=EST5EDT
else TZ=PST8PDT
fi
export TZ
crond -c /data/cron


# enable sysctl tweaks

sysctl -p /system/etc/systctl.conf

SAMPLING_RATE=$(busybox expr `cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency` \* 750 / 1000)
echo 95 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
echo $SAMPLING_RATE > /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate



# if swapfile exists, enable swap and adjust other settings
if [ -f /data/swap ]; then
  swapon /data/swap
  echo "100,200,20000,20000,20000,25000" > /sys/module/lowmemorykiller/parameters/minfree
  sysctl -w vm.swappiness=40
fi

# disable logger - performance boost & save memory (comment and reboot for logcat)
rm /dev/log/main


# file system speedups
busybox mount -o remount,noatime,barrier=0,nobh /system
busybox mount -o remount,noatime,barrier=0,nobh /data
busybox mount -o remount,noatime,barrier=0,nobh /cache


# sd card speed boost
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
  echo 1024 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
fi